package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ImpPopBg;
import com.ruoyi.system.service.IImpPopBgService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 重点人口变更信息Controller
 * 
 * @author ruoyi
 * @date 2024-10-15
 */
@Controller
@RequestMapping("/system/zd_bg")
public class ImpPopBgController extends BaseController
{
    private String prefix = "system/zd_bg";

    @Autowired
    private IImpPopBgService impPopBgService;

    @RequiresPermissions("system:zd_bg:view")
    @GetMapping()
    public String zd_bg()
    {
        return prefix + "/zd_bg";
    }

    /**
     * 查询重点人口变更信息列表
     */
    @RequiresPermissions("system:zd_bg:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ImpPopBg impPopBg)
    {
        startPage();
        List<ImpPopBg> list = impPopBgService.selectImpPopBgList(impPopBg);
        return getDataTable(list);
    }

    /**
     * 导出重点人口变更信息列表
     */
    @RequiresPermissions("system:zd_bg:export")
    @Log(title = "重点人口变更信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ImpPopBg impPopBg)
    {
        List<ImpPopBg> list = impPopBgService.selectImpPopBgList(impPopBg);
        ExcelUtil<ImpPopBg> util = new ExcelUtil<ImpPopBg>(ImpPopBg.class);
        return util.exportExcel(list, "重点人口变更信息数据");
    }

    /**
     * 新增重点人口变更信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存重点人口变更信息
     */
    @RequiresPermissions("system:zd_bg:add")
    @Log(title = "重点人口变更信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ImpPopBg impPopBg)
    {
        return toAjax(impPopBgService.insertImpPopBg(impPopBg));
    }

    /**
     * 修改重点人口变更信息
     */
    @RequiresPermissions("system:zd_bg:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ImpPopBg impPopBg = impPopBgService.selectImpPopBgById(id);
        mmap.put("impPopBg", impPopBg);
        return prefix + "/edit";
    }

    /**
     * 修改保存重点人口变更信息
     */
    @RequiresPermissions("system:zd_bg:edit")
    @Log(title = "重点人口变更信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ImpPopBg impPopBg)
    {
        return toAjax(impPopBgService.updateImpPopBg(impPopBg));
    }

    /**
     * 删除重点人口变更信息
     */
    @RequiresPermissions("system:zd_bg:remove")
    @Log(title = "重点人口变更信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(impPopBgService.deleteImpPopBgByIds(ids));
    }
}
